<template>
  <div>
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>设备属性</span>
        <el-button style="float: right; padding: 3px 0" type="text" @click="getMe" class="el-icon-refresh"></el-button>
<!--        <el-button style="float: right; padding: 3px 0" type="text" @click="getMe"><i class="el-icon-edit"></i></el-button>-->
      </div>
      <div class="text item">名称： {{ me.name }}</div>
      <div class="text item">uuid： {{ me.uuid }}</div>
      <div class="text item">厂商： {{ me.manufacturer }}</div>
      <div class="text item">产品名称： {{ me["product-name"] }}</div>
      <div class="text item">设备状态： {{ me.status }}</div>
      <div class="text item">软件版本： {{ me["software-version"] }}</div>
      <div class="text item">硬件版本： {{ me["hardware-version"] }}</div>
      <div class="text item">类型： {{ me["device-type"] }}</div>
      <div class="text item">支持协议：
        <span v-for="(i,key) in me['layer-protocol-name']" :key="key">
          <i style="color: #0038f5">{{ i }}</i>
          <el-divider direction="vertical" v-if="key!==me['layer-protocol-name'].length-1"></el-divider>
        </span>
      </div>
      <div class="text item">ip： {{ me["ip-address"] }}</div>
      <div class="text item">掩码： {{ me.mask }}</div>
      <div class="text item">way1： {{ me["gate-way1"] }}</div>
      <div class="text item">way2： {{ me["gate-way2"] }}</div>
      <div class="text item">ntp状态： {{ me["ntp-enable"] }}</div>
    </el-card>

  </div>
</template>

<script>
import axios from "axios";

export default {
  name: "MePac",
  props: ['name'],
  data() {
    return {
      isMe: false,
      me: {
        "hardware-version": "pvb 1.2.3.6",
        "ntp-enable": false,
        "eq": [],
        "uuid": "22-3d-12-88",
        "manufacturer": "山东华辰泰尔",
        "software-version": "v1.0.0.0.4",
        "ip-address": "192.168.12.112",
        "layer-protocol-name": [
          "acc-eth:ETH",
          "acc-otn:ODU",
        ],
        "device-type": "OTN-A6",
        "name": "otna",
        "ntp-servers": {
          "ntp-server": [
            {
              "port": 0,
              "name": "hctel"
            }
          ]
        },
        "product-name": "山东华辰泰尔",
        "gate-way1": "192.168.1.1",
        "gate-way2": "192.168.1.2",
        "status": "运行中",
        "mask": "255.255.0.0"
      },
    }
  },
  methods: {
    getMe() {
      console.log("---===",this.name);
      if (this.name !== '') {
        axios.get("/topology/node/" + this.name + "/me").then(
            response => {
              console.log("请求成功", response.data);
              this.$message.success("获取设备信息成功");
              this.me = response.data;
            },
            error => {
              console.log("失败！", error.message);
              this.$message.error(error.message);
            }
        )
      } else {
        this.$message.warning("请选择节点后再进行操作 ！")
      }

    },
  },
  created() {
    this.getMe();
  }
}
</script>

<style scoped>

</style>